package com.heima.schedule.feign;


import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.schedule.dtos.TaskDto;
import com.heima.schedule.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/vi/task")
public class ScheduleClient {

    @Autowired
    private TaskService taskService;

    /**
     * 添加任务
     * @param dto 任务对象
     * @return  任务Id
     */
    @PostMapping("/add")
    public ResponseResult addTask(@RequestBody TaskDto dto){
        return ResponseResult.okResult(taskService.addTask(dto));
    }

    /**
     * 拉取消费任务
     * @param type
     * @param priority
     * @return
     */
    @GetMapping("/{type}/{priority}")
    public ResponseResult popTak(@PathVariable("type") Integer type ,@PathVariable("priority")  Integer priority){
        return ResponseResult.okResult(taskService.popTak(type,priority));
    }
}
